package com.xgpro.pc.rolemanage.service.impl;

import com.xgpro.domain.rolemanage.entity.Department;
import com.xgpro.mapper.rolemanage.DepartmentMapper;
import com.xgpro.pc.rolemanage.service.DepartmentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;

/**
 * @program: xgpro__dev
 * @description: 部门接口
 * @author: likai
 * @create: 2019-10-13 15:17
 **/

@Service
@Transactional
public class DepartmentServiceImpl implements DepartmentService {

    @Resource
    private DepartmentMapper departmentMapper;

    @Override
    public void addDept(Department department) {
        departmentMapper.insert(department);

    }

    @Override
    public Department findOne(Integer deptId) {
        return departmentMapper.selectByPrimaryKey(deptId);
    }

    @Override
    public int countByDDId(String deptDDId) {

        Example example = new Example(Department.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("ddId",deptDDId);
        int cnt = departmentMapper.selectCountByExample(example);
        return cnt;
    }

    @Override
    public void update(Department department) {
        departmentMapper.updateByPrimaryKeySelective(department);
    }
}
